package com.senriot.quickup.web.rest

import cn.hutool.http.HttpUtil
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.multipart.MultipartFile
import org.springframework.core.io.InputStreamResource
import java.util.HashMap



@RestController
@RequestMapping("api/file")
class FileResource
{
    @PostMapping("upload")
    fun upload(@RequestParam("file") file: MultipartFile): String?
    {
        val isr = InputStreamResource(file.inputStream,
                file.originalFilename)

        val params = HashMap<String, Any>()
        params["file"] = isr
        params["path"] = "86501729"
        params["output"] = "json"
        return HttpUtil.post("http://file.kuaixing.vip/group1/upload", params)
}
}
